<!DOCTYPE html>
<html>
<head>
<title>系统设置</title>
#include("../include/common.html")
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>系统设置</h5>
            </div>
           <form id="inputForm" action="update" method="post">
               <div class="tabs-container">
                   <ul class="nav nav-tabs">
                        <li class="active"><a data-toggle="tab" href="#tab-1">网站设置</a></li>
                        <li class=""><a data-toggle="tab" href="#tab-2">存储设置</a></li>
                        <li class=""><a data-toggle="tab" href="#tab-3">短信设置</a></li>
                        <li class=""><a data-toggle="tab" href="#tab-4">物流设置</a></li>
                        <li class=""><a data-toggle="tab" href="#tab-5">微信设置</a></li>
                        <li class=""><a data-toggle="tab" href="#tab-6">支付宝设置</a></li>
                    </ul>
                    <div class="tab-content">
                        <div id="tab-1" class="tab-pane active">
                            <div class="panel-body form-horizontal">
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">网站名称：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="siteName" value="#(config.siteName)">
			                        </div>
			                    </div>
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">网站网址：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="siteUrl" value="#(config.siteUrl)">
			                        </div>
			                    </div>
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">logo：</label>
			                        <div class="col-sm-3" id="fileImage">
		                                 #if(config.logo??)
		                                 <img alt="" src="#(imageUrl(config.logo))" height="110"><input type="hidden" name="logo" value="#(config.logo)"/>
		                                 #end
		                             </div>
		                             <div class="col-sm-3">
		                                 <a href="javascript:;" id="filePicker" class="btn btn-primary">选择文件</a>
		                             </div>
			                    </div>
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">标题：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="title" value="#(config.title)">
			                        </div>
			                    </div>
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">关键词：</label>
			                        <div class="col-sm-3">
			                            <textarea class="form-control" style="height: 50px;" name="keywords">#(config.keywords)</textarea>
			                        </div>
			                    </div>
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">描述：</label>
			                        <div class="col-sm-3">
			                            <textarea class="form-control" style="height: 50px;" name="description">#(config.description)</textarea>
			                        </div>
			                    </div>
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">主题：</label>
			                        <div class="col-sm-3">
			                            <select class="form-control" name="theme">
			                                #for(theme : themes)
											 	<option value="#(theme)" #if(theme==config.theme) selected #end>#(theme)</option> 
											#end
			                            </select>
			                        </div>
			                    </div>
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">图片域名：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="imgUrl" value="#(config.imgUrl)">
			                        </div>
			                    </div>
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">热门搜索：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="searchWord" value="#(config.searchWord)">
			                        </div>
			                    </div>
		                    </div>
	                    </div>
	                    <div id="tab-2" class="tab-pane active">
                            <div class="panel-body form-horizontal">
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">OSS endpoint：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="oss_endpoint" value="#(config.oss_endpoint)">
			                        </div>
			                    </div>
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">OSS accessId：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="oss_accessId" value="#(config.oss_accessId)">
			                        </div>
			                    </div>
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">OSS accessKey：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="oss_accessKey" value="#(config.oss_accessKey)">
			                        </div>
			                    </div>
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">OSS bucket：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="oss_bucket" value="#(config.oss_bucket)">
			                        </div>
			                    </div>
		                   	</div>
	                   	</div>
	                   	<div id="tab-3" class="tab-pane active">
                            <div class="panel-body form-horizontal">
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">短信签名：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="sms_signName" value="#(config.sms_signName)">
			                        </div>
			                    </div>
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">短信accessKey：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="sms_accessKey" value="#(config.sms_accessKey)">
			                        </div>
			                    </div>
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">短信accessSecret：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="sms_accessSecret" value="#(config.sms_accessSecret)">
			                        </div>
			                    </div>
		                   	</div>
	                   	</div>
	                   	<div id="tab-4" class="tab-pane active">
                            <div class="panel-body form-horizontal">
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">物流appCode：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="wuliu_code" value="#(config.wuliu_code)">
			                        </div>
			                    </div>
		                   	</div>
	                   	</div>
	                   	<div id="tab-5" class="tab-pane active">
                            <div class="panel-body form-horizontal">
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">微信公众号appId：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="weixin_wechatAppId" value="#(config.weixin_wechatAppId)">
			                        </div>
			                    </div>
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">微信公众号secret：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="weixin_wechatSecret" value="#(config.weixin_wechatSecret)">
			                        </div>
			                    </div>
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">微信小程序appId：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="weixin_xcxAppId" value="#(config.weixin_xcxAppId)">
			                        </div>
			                    </div>
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">微信小程序secret：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="weixin_xcxSecret" value="#(config.weixin_xcxSecret)">
			                        </div>
			                    </div>
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">微信开放平台appId：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="weixin_openAppId" value="#(config.weixin_openAppId)">
			                        </div>
			                    </div>
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">微信支付商户号：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="weixin_mchId" value="#(config.weixin_mchId)">
			                        </div>
			                    </div>
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">微信支付应用ID：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="weixin_mchAppId" value="#(config.weixin_mchAppId)">
			                        </div>
			                    </div>
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">微信支付密钥：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="weixin_key" value="#(config.weixin_key)">
			                        </div>
			                    </div>
		                   	</div>
	                   	</div>
	                   	<div id="tab-6" class="tab-pane active">
                            <div class="panel-body form-horizontal">
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">支付宝appId：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="alipay_appId" value="#(config.alipay_appId)">
			                        </div>
			                    </div>
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">支付宝app私钥：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="alipay_appPrivateKey" value="#(config.alipay_appPrivateKey)">
			                        </div>
			                    </div>
			                    <div class="form-group">
			                        <label class="col-sm-3 control-label">支付宝公钥：</label>
			                        <div class="col-sm-3">
			                            <input class="form-control" type="text" name="alipay_publicKey" value="#(config.alipay_publicKey)">
			                        </div>
			                    </div>
		                   	</div>
	                   	</div>
	                </div>
	            </div>
	            <div class="modal-footer col-sm-3 col-sm-offset-2">
	                <button type="submit" class="btn btn-w-m btn-primary">确定</button>
	            </div>
            </form>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
function fileUploadCall(fromType,url){
	var html='<img alt="" src="'+url+'" height="110"><input type="hidden" name="logo" value="'+url+'"/>';
	$("#fileImage").html(html);
}

$().ready(function() {

	var $inputForm = $("#inputForm");
	
	var $filePicker = $("#filePicker");

	$filePicker.uploader();
    
	
    // 表单验证
    $inputForm.validate({
        rules: {
            siteName: "required",
            siteUrl: {
                required: true,
                pattern: /^(http:\/\/|https:\/\/).*$/i
            },
            logo: {
                required: true
            }
        },submitHandler: function(form) {
        	$.ajax({
    	        url: "#(base)/admin/setup/update",
    	        type: "POST",
    	        data: $("#inputForm").serialize(),
    	        dataType: "json",
    	        cache: false,
    	        success: function(response) {
    	            if (response.type == "success") {
    	            	swal({title:'', text:'操作成功',icon: 'success'});
    	            }else{
    	                swal({title:'', text:response.msg,icon: 'error'});
    	            }
    	        }
    	    });
    		return false;
		}
    });
});
</script>